<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="${daoUrl}.${entityName}Dao">

	<resultMap id="BaseResultMap" type="${entityUrl}.${entityName}">
	<#list cis as ci>
		<id column="${ci.column}" property="${ci.property}" />
	</#list>
	</resultMap>
	<sql id="Base_Column_List">
		${agile}
	</sql>
	 <!--新增${entityComment}-->
	<insert id="insert"  parameterType="${entityUrl}.${entityName}">
    		insert into ${table}

    		<trim prefix="(" suffix=")" suffixOverrides=",">
                <#list cis as ci>
                    <if test="${ci.property} != null">
                        ${ci.column},
                    </if>
                </#list>
    		</trim>
    		<trim prefix="values (" suffix=")" suffixOverrides=",">
                <#list cis as ci>
                    <if test="${ci.property} != null">
                       ${r"#{"}${ci.property} ,jdbcType=${ci.jdbcType} ${r"}"},
                    </if>
               </#list>
    		</trim>
    	</insert>
    	<!--修改${entityComment}-->
    	<update id="update"  parameterType="${entityUrl}.${entityName}">
            update ${table}
             <set>
               <#list cis as ci>
                  <if test="${ci.property} != null">
                    ${ci.column} = ${r"#{"}${ci.property} ,jdbcType=${ci.jdbcType} ${r"}"},
                  </if>
              </#list>
             </set>
             <where>
              <#list cis as ci>
                 <if test="${ci.property} != null">
                  ${r"and"} ${ci.column} = ${r"#{"}${ci.property} ,jdbcType=${ci.jdbcType} ${r"}"}
                </if>
               </#list>
             </where>

       </update>
       <!--获取${entityComment}的详情-->
    <select id="getById" resultMap="BaseResultMap" parameterType="java.lang.Integer">
        select
        <include refid="Base_Column_List" />
        from ${table}
        <where>
         ${r"and id "}=${r"#{id"},jdbcType=${r"INTEGER }"}
         </where>
    </select>
   <!--删除${entityComment}-->
    <delete id="deleteById"  parameterType="java.lang.Integer">
        delete from ${table}
        <where>
            ${r"and id"}=${r"#{id"},jdbcType=${r"INTEGER }"}
         </where>
     </delete>

     <insert id="batchInsert" parameterType="java.util.List">
     		insert into ${table}(${agile})
     		values
     		<foreach collection="list" item="item" index="index"
     				 separator=",">
     			(
     			<#list cis as ci>
                 ${ r"#{item."}${ci.property}  ,jdbcType=${ci.jdbcType} ${r"}"} <#if ci_has_next>,</#if>
               </#list>
     			)
     		</foreach>
     	</insert>
</mapper>